package nuc.edu.tlias.controller;

import lombok.extern.slf4j.Slf4j;
import nuc.edu.tlias.pojo.Result;

import nuc.edu.tlias.utils.AliyunOSSOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
public class UploadController {
    @Autowired
    private AliyunOSSOperator aliyunOSSOperator;


    @PostMapping("/upload")
    public Result upload(String name, Integer age, MultipartFile file) throws Exception {
        log.info("接受参数：{},{},{}",name,age,file);

        //文件上传的url
        String url = aliyunOSSOperator.upload(file.getBytes(), file.getOriginalFilename());


        return Result.success(url);

    }
}
